package com.xingdata.jjxc.activity.viewdata;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.xingdata.jjxc.R;
import com.xingdata.jjxc.activity.CarInfoListViewActivity;
import com.xingdata.jjxc.activity.DrivingHabitsListView;
import com.xingdata.jjxc.activity.MapActivity;
import com.xingdata.jjxc.activity.OBDActivity;
import com.xingdata.jjxc.activity.TravelRecordListView;
import com.xingdata.jjxc.activity.VideoActivity;
import com.xingdata.jjxc.circlemenu.CircleLayout;
import com.xingdata.jjxc.circlemenu.CircleLayout.OnItemClickListener;
import com.xingdata.jjxc.circlemenu.CircleLayout.OnItemSelectedListener;
import com.xingdata.jjxc.utils.Constants;

public class CarInfoViewData implements OnClickListener,OnItemSelectedListener, OnItemClickListener {
	final static String TAG = "CarInfoViewData";
	private View tablView;
	Context context;
	Handler mhandler;
	
	TextView selectedTextView;

//	@Override
//	protected void onCreate(Bundle savedInstanceState) {
//		// TODO Auto-generated method stub
//		super.onCreate(savedInstanceState);
//		setContentView(R.layout.activity_main);
//		
//		Log.d(TAG, "2");
//		
//		CircleLayout circleMenu = (CircleLayout) findViewById(R.id.main_circle_layout);
//		circleMenu.setOnItemClickListener((OnItemClickListener) this);
//
//		selectedTextView = (TextView) findViewById(R.id.main_selected_textView);
//		selectedTextView.setText(((CircleImageView2) circleMenu.getSelectedItem()).getName());
//	}
	
	@Override
	public void onItemClick(View view) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onItemSelected(View view) {
		// TODO Auto-generated method stub
		
	}
	
	public CarInfoViewData(View tabView, Context context, Handler mhandler) {
		Log.d(TAG, "3"); 
		this.tablView = tabView;
		this.context = context;
		this.mhandler = mhandler;
		initview();
//		((Activity) getBaseContext()).getLayoutInflater().inflate(R.layout.activity_main, null);
	}
	
	private void initview() {
//		View.inflate(context, R.layout.activity_main, (ViewGroup) tablView);
//		View.inflate(context, R.layout.activity_main, null);

		((ImageView) tablView.findViewById(R.id.OBD)).setOnClickListener(this);
		((ImageView) tablView.findViewById(R.id.jsxg)).setOnClickListener(this);
		((ImageView) tablView.findViewById(R.id.xcjly)).setOnClickListener(this);
		((ImageView) tablView.findViewById(R.id.acxx)).setOnClickListener(this);
		((ImageView) tablView.findViewById(R.id.lcjl)).setOnClickListener(this);
		((ImageView) tablView.findViewById(R.id.zhaoche)).setOnClickListener(this);

		// 动态加载activity_main布局界面
//		LayoutInflater flater = LayoutInflater.from(this.context);
//		View view = flater.inflate(R.layout.activity_main, null);

		// 设置圆形菜单布局点击事件
		CircleLayout circleMenu = (CircleLayout) tablView.findViewById(R.id.main_circle_layout);
		circleMenu.setOnItemClickListener((OnItemClickListener) this);

		// 设置文件显示
//		selectedTextView = (TextView) tablView.findViewById(R.id.main_selected_textView);
//		selectedTextView.setText(((CircleImageView2) circleMenu.getSelectedItem()).getName());
		
		TextView title = (TextView) tablView.findViewById(R.id.title);
		title.setText("爱车");
	}

	@Override
	public void onClick(View v) {
		Intent intent = null;
		switch (v.getId()) {
		// OBD数据
		case R.id.OBD:
			intent = new Intent(context, OBDActivity.class);
			context.startActivity(intent);
			break;
		// 驾驶习惯
		case R.id.jsxg:
			intent = new Intent(context, DrivingHabitsListView.class);
			context.startActivity(intent);
			break;
		// 行车记录仪
		case R.id.xcjly:
			intent = new Intent(context, VideoActivity.class);
			context.startActivity(intent);
			break;
		// 爱车信息
		case R.id.acxx:
			intent = new Intent(context, CarInfoListViewActivity.class);
			context.startActivity(intent);
			break;
		// 找车
		case R.id.zhaoche:
			Bundle bundle = new Bundle();
			bundle.putInt("inNaviLocionType", Constants.INTENT_FINDCAR);
			intent = new Intent(context, MapActivity.class);
			intent.putExtras(bundle);
			context.startActivity(intent);
			break;
		// 里程记录
		case R.id.lcjl:
			intent = new Intent(context, TravelRecordListView.class);
			context.startActivity(intent);
		default:
			break;
		}
	}

	
	
}
